/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ipo.mm.web.filters;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 *
 * @author makcro
 */
public class EncodingFilter implements Filter {

    private String encodingUTF8 = "UTF-8";
    private String encodingISO88592 = "ISO-8859-2";
    private String encoding;
    public void init(FilterConfig filterConfig) throws ServletException {
        String encodingParam = filterConfig.getInitParameter("encoding");
        if (encodingParam == null) {
            encoding = encodingUTF8;
        }
    }

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
       request.setCharacterEncoding(encodingUTF8);
       response.setCharacterEncoding(encodingUTF8);
       chain.doFilter(request, response);
    }

    public void destroy() {
    }
}
